Change in openvpn[master]: Do not check key_state buffers that are in S_UNDEF state
A message that is not in the archive (sent off-list or not yet received): gerrit.1699712500000.I226a73d47a2b1b29f7ec175ce23a806593abc2ac@...2715...
Attention is currently required from: flichtenheld.
Hello flichtenheld,
I'd like you to do a code review.
Please visit
http://gerrit.openvpn.net/c/openvpn/+/426?usp=email
to review the following change.
Change subject: Do not check key_state buffers that are in S_UNDEF state
......................................................................
Do not check key_state buffers that are in S_UNDEF state
When a key_state is in S_UNDEF the send_reliable is not initialised. So checking it might access invalid memory or null pointers.
Change-Id: I226a73d47a2b1b29f7ec175ce23a806593abc2ac
---
M src/openvpn/ssl.c
1 file changed, 5 insertions(+), 0 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/26/426/1
src/openvpn/ssl.c +5 -0
@@ -3189,6 +3189,11 @@for (int i =0 ; i <KS_SIZE ; i++) {struct key_state *ks = &session->key[i]; +if (ks->state ==S_UNDEF ) + { +continue ; + } +for (int j =0 ; j < ks->send_reliable->size; j++) {if (ks->send_reliable->array[i].buf.data == dataptr)
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/426?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I226a73d47a2b1b29f7ec175ce23a806593abc2ac
Gerrit-Change-Number: 426
Gerrit-PatchSet: 1
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-MessageType: newchange
Attention is currently required from: flichtenheld, plaisthos.
ordex has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/426?usp=email )
Change subject: Do not check key_state buffers that are in S_UNDEF state
......................................................................
Patch Set 1: Code-Review+2
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/426?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I226a73d47a2b1b29f7ec175ce23a806593abc2ac
Gerrit-Change-Number: 426
Gerrit-PatchSet: 1
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: ordex <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Wed, 15 Nov 2023 09:47:11 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
Attention is currently required from: flichtenheld, plaisthos.
ordex has removed a vote from this change. ( http://gerrit.openvpn.net/c/openvpn/+/426?usp=email )
Change subject: Do not check key_state buffers that are in S_UNDEF state
......................................................................
Removed Code-Review+2 by ordex <[email protected]...>
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/426?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I226a73d47a2b1b29f7ec175ce23a806593abc2ac
Gerrit-Change-Number: 426
Gerrit-PatchSet: 1
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: ordex <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-MessageType: deleteVote
Attention is currently required from: flichtenheld, plaisthos.
ordex has uploaded a new patch set (#2) to the change originally created by plaisthos. ( http://gerrit.openvpn.net/c/openvpn/+/426?usp=email )
Change subject: Do not check key_state buffers that are in S_UNDEF state
......................................................................
Do not check key_state buffers that are in S_UNDEF state
When a key_state is in S_UNDEF the send_reliable is not initialised. So checking it might access invalid memory or null pointers.
---
M src/openvpn/ssl.c
1 file changed, 16 insertions(+), 0 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/26/426/2
src/openvpn/ssl.c +16 -0
@@ -3189,6 +3189,22 @@for (int i =0 ; i <KS_SIZE ; i++) {struct key_state *ks = &session->key[i]; +if (ks->state ==S_UNDEF ) + { +continue ; + } + +/* we don't expect send_reliable to be NULL when state is +* not S_UNDEF, but people have reported crashes nonetheless, +* therefore we better catch this event, report and exit. +*/ +if (!ks->send_reliable) + { +msg (M_FATAL ,"ERROR: session->key[%d]->send_reliable is NULL " +"while key state is %s. Exiting." , + i,state_name (ks->state)); + } +for (int j =0 ; j < ks->send_reliable->size; j++) {if (ks->send_reliable->array[i].buf.data == dataptr)
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/426?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I226a73d47a2b1b29f7ec175ce23a806593abc2ac
Gerrit-Change-Number: 426
Gerrit-PatchSet: 2
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: ordex <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-MessageType: newpatchset
Attention is currently required from: flichtenheld, ordex, plaisthos.
cron2 has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/426?usp=email )
Change subject: Do not check key_state buffers that are in S_UNDEF state
......................................................................
Patch Set 2: Code-Review+2
(1 comment)
File src/openvpn/ssl.c:
http://gerrit.openvpn.net/c/openvpn/+/426/comment/096ce4c5_5a724a5c :
PS1, Line 3192: if (ks->state == S_UNDEF)
the crashdump / backtraces I received today confirm that this is the root cause, ks->state == S_UNDEF and thus, ks->send_reliable == NULL.
I'd feel a bit more comfortable to check "if (ks->send_reliable)" here, though - so we're not ending in a crash here again should another state be introduced in 2.8 where ks->state is something like "S_CLEARED" and bäm, NULL pointer access again.
(We can check both, and complain if ks->send_reliable is NULL if ks->state is *not* S_UNDEF)
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/426?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I226a73d47a2b1b29f7ec175ce23a806593abc2ac
Gerrit-Change-Number: 426
Gerrit-PatchSet: 2
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: ordex <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: ordex <[email protected]...>
Gerrit-Comment-Date: Wed, 15 Nov 2023 10:29:06 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
PATCH v2 1/1 Do not check key_state buffers that are in S_UNDEF state
In reply to a message not in the archiveFrom: Arne Schwabe <[email protected]...>
When a key_state is in S_UNDEF the send_reliable is not initialised. So checking it might access invalid memory or null pointers.
Github: fixes OpenVPN/openvpn#449
---
This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/426
This mail reflects revision 2 of this Change. Acked-by according to Gerrit (reflected above):
Gert Doering <[email protected]...>
src/openvpn/ssl.c +16 -0
@@ -3189,6 +3189,22 @@for (int i =0 ; i <KS_SIZE ; i++) {struct key_state *ks = &session->key[i]; +if (ks->state ==S_UNDEF ) + { +continue ; + } + +/* we don't expect send_reliable to be NULL when state is +* not S_UNDEF, but people have reported crashes nonetheless, +* therefore we better catch this event, report and exit. +*/ +if (!ks->send_reliable) + { +msg (M_FATAL ,"ERROR: session->key[%d]->send_reliable is NULL " +"while key state is %s. Exiting." , + i,state_name (ks->state)); + } +for (int j =0 ; j < ks->send_reliable->size; j++) {if (ks->send_reliable->array[i].buf.data == dataptr)
[Openvpn-devel] [PATCH applied] Re: Do not check key_state buffers that are in S_UNDEF state
I have tested the "lite" version of that patch (only the S_UNDEF patch) for 30+ hours in a scenario that managed to crash after a few hours without it, so am reasonably confident it fixes the 2.6.7 crashes observed - in case there *are* other cases, we added a M_FATAL so we stop with a debug note, and do not SIGSEGV. This really is a "can't happen", but *if* it does, we want to know.
Your patch has been applied to the master and release/2.6 branch.
commit a903ebe9361d451daee71c225e141f4e1b67107d (master) commit b90ec6dabfb151dd93ef00081bbc3f55e7d3450f (release/2.6)
Author: Arne Schwabe Date: Wed Nov 15 11:33:31 2023 +0100
Do not check key_state buffers that are in S_UNDEF state
Signed-off-by: Arne Schwabe <[email protected]...>
Acked-by: Gert Doering <[email protected]...>
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg27401.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
cron2 has uploaded a new patch set (#3) to the change originally created by plaisthos. ( http://gerrit.openvpn.net/c/openvpn/+/426?usp=email )
The following approvals got outdated and were removed:
Code-Review+2 by cron2
Change subject: Do not check key_state buffers that are in S_UNDEF state
......................................................................
Do not check key_state buffers that are in S_UNDEF state
When a key_state is in S_UNDEF the send_reliable is not initialised. So checking it might access invalid memory or null pointers.
Github: fixes OpenVPN/openvpn#449
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg27401.html
---
M src/openvpn/ssl.c
1 file changed, 16 insertions(+), 0 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/26/426/3
src/openvpn/ssl.c +16 -0
@@ -3189,6 +3189,22 @@for (int i =0 ; i <KS_SIZE ; i++) {struct key_state *ks = &session->key[i]; +if (ks->state ==S_UNDEF ) + { +continue ; + } + +/* we don't expect send_reliable to be NULL when state is +* not S_UNDEF, but people have reported crashes nonetheless, +* therefore we better catch this event, report and exit. +*/ +if (!ks->send_reliable) + { +msg (M_FATAL ,"ERROR: session->key[%d]->send_reliable is NULL " +"while key state is %s. Exiting." , + i,state_name (ks->state)); + } +for (int j =0 ; j < ks->send_reliable->size; j++) {if (ks->send_reliable->array[i].buf.data == dataptr)
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/426?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I226a73d47a2b1b29f7ec175ce23a806593abc2ac
Gerrit-Change-Number: 426
Gerrit-PatchSet: 3
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: ordex <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: newpatchset
cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/426?usp=email )
Change subject: Do not check key_state buffers that are in S_UNDEF state
......................................................................
Do not check key_state buffers that are in S_UNDEF state
When a key_state is in S_UNDEF the send_reliable is not initialised. So checking it might access invalid memory or null pointers.
Github: fixes OpenVPN/openvpn#449
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg27401.html
---
M src/openvpn/ssl.c
1 file changed, 16 insertions(+), 0 deletions(-)
src/openvpn/ssl.c +16 -0
@@ -3189,6 +3189,22 @@for (int i =0 ; i <KS_SIZE ; i++) {struct key_state *ks = &session->key[i]; +if (ks->state ==S_UNDEF ) + { +continue ; + } + +/* we don't expect send_reliable to be NULL when state is +* not S_UNDEF, but people have reported crashes nonetheless, +* therefore we better catch this event, report and exit. +*/ +if (!ks->send_reliable) + { +msg (M_FATAL ,"ERROR: session->key[%d]->send_reliable is NULL " +"while key state is %s. Exiting." , + i,state_name (ks->state)); + } +for (int j =0 ; j < ks->send_reliable->size; j++) {if (ks->send_reliable->array[i].buf.data == dataptr)
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/426?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I226a73d47a2b1b29f7ec175ce23a806593abc2ac
Gerrit-Change-Number: 426
Gerrit-PatchSet: 3
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: ordex <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: merged